package com.dingreading.cloud.app.service.impl;

import com.dingreading.cloud.app.entity.Relatives;
import com.dingreading.cloud.app.entity.table.RelativesTableDef;
import com.dingreading.cloud.app.mapper.RelativesMapper;
import com.dingreading.cloud.app.service.RelativesService;
import com.mybatisflex.core.query.QueryCondition;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 服务层实现。
 *
 * @author Administrator
 * @since 2023-11-22
 */
@Service
public class RelativesServiceImpl extends BaseServiceImpl<RelativesMapper, Relatives, RelativesTableDef> implements RelativesService {

    @Override
    protected RelativesTableDef getTable() {
        return RelativesTableDef.relatives;
    }

    /**
     * 按会员id、公众号openid、推送状态，查找会员的亲属
     *
     * @param memberId 会员id
     * @param gzhPush  推送状态
     * @return list
     */
    @Override
    public List<Relatives> getByMemberIdAndGzhOpenIdAndGzhPush(Long memberId, Integer gzhPush) {
        QueryCondition condition = QueryCondition.createEmpty();
        condition.and(table.memberId.eq(memberId))
                .and(table.gzhOpenId.isNotNull())
                .and(table.gzhPush.eq(gzhPush));
        return getMapper().selectListByCondition(condition);
    }

}
